package demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-19
 * Time: 10:37
 */
public class Person implements Cloneable{
    public String name;
    public int age;
    Money m = new Money();
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    /*@Override
    protected Object clone()
            throws CloneNotSupportedException {
        return super.clone();
    }//浅拷贝*/
    @Override
    protected Object clone()
            throws CloneNotSupportedException {
        Person tmp = (Person) super.clone();
        tmp.m = (Money) this.m.clone();
        return tmp;
    }
}
